package com.huqing.icu.dao;

import com.huqing.icu.dto.ChatSessionQueryDto;
import com.huqing.icu.mapper.ChatSessionMapper;
import com.huqing.icu.model.ChatSession;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Description 对话记录消息dao
 * @Author huqing
 * @Date 2025/7/26 17:39
 **/
@Repository
public class ChatSessionDao {

    @Resource
    private ChatSessionMapper chatSessionMapper;


    public Integer saveOrUpdate(ChatSession chatSession) {
        if (chatSession.getId() == null) {
            return chatSessionMapper.insert(chatSession);
        } else {
            return chatSessionMapper.updateById(chatSession);
        }
    }

    public ChatSession selectByIdAndUserId(Long id, Long userId) {
        return chatSessionMapper.selectByIdAndUserId(id, userId);
    }

    public Integer deleteById(Long id, Long userId) {
        return chatSessionMapper.deleteById(id, userId);
    }

    public Integer getNumByUserId(Long userId) {
        return chatSessionMapper.getNumByUserId(userId);
    }

    public List<ChatSession> selectByCondition(ChatSessionQueryDto queryDto) {
        return chatSessionMapper.selectByCondition(queryDto);
    }

    public ChatSession selectById(Long id) {
        return chatSessionMapper.selectById(id);
    }
}
